home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 16 / AMIGAplus Sonderheft 16 (1998)(ICP)(DE)[!].iso / pd / anwendungen / ispell-3.1.18src / makeshar (.txt) < prev    next >
Microsoft Windows Help File Content  |  1994-01-25  |  4KB  |  122 lines

  1. : Use /bin/sh
  2. # $Id: makeshar,v 1.7 1994/01/25 07:11:57 geoff Exp $
  3. # Copyright 1993, Geoff Kuenning, Granada Hills, CA
  4. # All rights reserved.
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions
  7. # are met:
  8. # 1. Redistributions of source code must retain the above copyright
  9. #    notice, this list of conditions and the following disclaimer.
  10. # 2. Redistributions in binary form must reproduce the above copyright
  11. #    notice, this list of conditions and the following disclaimer in the
  12. #    documentation and/or other materials provided with the distribution.
  13. # 3. All modifications to the source code must be clearly marked as
  14. #    such.  Binary redistributions based on modified source code
  15. #    must be clearly marked as modified versions in the documentation
  16. #    and/or other materials provided with the distribution.
  17. # 4. All advertising materials mentioning features or use of this software
  18. #    must display the following acknowledgment:
  19. #      This product includes software developed by Geoff Kuenning and
  20. #      other unpaid contributors.
  21. # 5. The name of Geoff Kuenning may not be used to endorse or promote
  22. #    products derived from this software without specific prior
  23. #    written permission.
  24. # THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS IS'' AND
  25. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27. # ARE DISCLAIMED.  IN NO EVENT SHALL GEOFF KUENNING OR CONTRIBUTORS BE LIABLE
  28. # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  30. # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  31. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  32. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  33. # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  34. # SUCH DAMAGE.
  35. # Make a shar file, keeping file sizes below a maximum, but as large as
  36. # possible.  The output files are put in file01.shar through filenn.shar,
  37. # where "file" is the output base name (default "prog").
  38. # If one of the output files is named "README", it is placed first in the
  39. # first shar file.
  40. # Usage:
  41. #    makeshar [-f n] [-n] [-m max-size] [-o output-base ] [shar-switches] file-list
  42. # $Log: makeshar,v $
  43. # Revision 1.7  1994/01/25  07:11:57  geoff
  44. # Get rid of all old RCS log lines in preparation for the 3.1 release.
  45. SHAR_SW=
  46. MAXSIZE=60000
  47. OUTPUT_BASE=prog
  48. NUM_SHARS=no
  49. FROM=1
  50. TMP=${TMPDIR:-/tmp}/ms$$
  51. while [ $# -gt 0 ]
  52.     case "$1" in
  53.         FROM=$2
  54.         shift; shift
  55.         ;;
  56.         MAXSIZE=$2
  57.         shift; shift
  58.         ;;
  59.         NUM_SHARS=yes
  60.         shift
  61.         ;;
  62.         OUTPUT_BASE="$2"
  63.         shift; shift
  64.         ;;
  65.         SHAR_SW="$SHAR_SW $1"
  66.         shift
  67.         ;;
  68.         break
  69.         ;;
  70.     esac
  71. trap "/bin/rm -f ${TMP}; exit 1" 1 2 15
  72. trap "/bin/rm -f ${TMP}; exit 0" 13
  73. sed -e "s;OUTPUT_BASE;$OUTPUT_BASE;" -e "s;SHAR_SW;$SHAR_SW;" \
  74.   -e "s;FROM;$FROM;" \
  75.   -e "s;MAXSIZE;$MAXSIZE;" > ${TMP} << 'EOF_AWK_SCRIPT'
  76.     BEGIN { nfiles = 0 }
  77.     if ($3 == "total")
  78.         next
  79.     # Shar adds one extra character per line
  80.     size[nfiles] = $1 + $2
  81.     files[nfiles] = $3
  82.     nfiles++
  83.     END \
  84.     outbase = "OUTPUT_BASE"
  85.     sharcount = FROM
  86.     for (filesdone = 0;  filesdone < nfiles;  sharcount++)
  87.         {
  88.         printf ("%s", "isharSHAR_SW")
  89.         totsize = 0
  90.         for (i = 0;  filesdone == 0  &&  i < nfiles;  i++)
  91.         if (files[i] == "README")
  92.             {
  93.             filesdone++
  94.             totsize += size[i]
  95.             printf (" %s", files[i])
  96.             files[i] = ""
  97.             size[i] = 0
  98.             }
  99.         for (i = 0;  totsize < MAXSIZE  &&  i < nfiles;  i++)
  100.         if (files[i] != "" \
  101.           &&  (totsize == 0  ||  size[i] < MAXSIZE - totsize))
  102.             {
  103.             filesdone++
  104.             totsize += size[i]
  105.             printf (" %s", files[i])
  106.             files[i] = ""
  107.             size[i] = 0
  108.             }
  109.         printf (" > %s%2.2d.shar\n", outbase, sharcount)
  110.         }
  111.     print "echo", sharcount - 1
  112. EOF_AWK_SCRIPT
  113. nshars=`wc -lc "$@" \
  114.   | sort -rn \
  115.   | awk -F ${TMP} \
  116.   | sh`
  117. if [ $NUM_SHARS = yes ]
  118.     echo $nshars
  119.     echo $nshars shar files:
  120.     ls -l $OUTPUT_BASE??.shar
  121. /bin/rm -f ${TMP}
  122.